<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
table.gridtable {
	font-family: verdana, arial, sans-serif;
	font-size: 11px;
	color: #333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}

table.gridtable th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}

table.gridtable td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}

tr:hover td {
	background: none;
}

tr:hover {
	background-color: none;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  padding: 8px;
  text-align: left;
}

th {
  background-color: #f2f2f2;
}
#myDiv {
     position: fixed;
     top: 30px;
     right: 0;
     background-color: #f1f1f1;
     padding: 10px;
   }
</style>
<meta charset="UTF-8">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.11.1.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/grid1.0.js"></script>
</head>
<body>
 
	<hr>
	<button id="addszList2">3更新深圳保存天数据300天</button>
	<button id="addszList1">2更新深圳下载天数据300天</button>
	<button id="addszList">1更新深圳最新天数据</button>
	<button id="addshList">更新上海最新天数据</button>
	<button id="addshList1">更新上海最新天数据300天</button>
	<button id="deleteSH">删除上海多余数据</button>
	<button id="addSN">更新所有股票的概念</button>
	<button id="addHS">计算最近一天换手率</button>
	<button id="addCls">加载财联社概念</button>
	<hr>
	<!-- <input type="text" id ="date" placeholder="20230419"> -->
	<button id="getSelect">计算日期后为全正的股票</button>
	<input type="text" id ="date1" placeholder="20230000" style="width:50px">
	<input type="text" id="zhang" value="4" style="width:50px">
	<button id="getSelect1">删除日期以前的计算结果</button>
	<input type="text" id ="date2" placeholder="涨跌大于5">
	<button id="getSelect2">计算涨跌数量决定股性</button>
	<hr>
	<button id="getContent">查询计算的数据</button>
	<select id="dateselect">
	
	</select>
	<span id="count"></span>
	<input type="text" id="numberMax" value="4" style="width:50px;" placeholder="大于多少总和的">
	<input type="text" id="numberMin" value="12" style="width:50px;" placeholder="小于多少总和的">
	<button id="bt1">筛选涨幅区间范围</button>

	<button id="bt2">按换手率排序</button>
	<button id="bt3">按涨5数据排序</button>
	<button id="bt4">按跌5数据排序</button>
	<button id="bt6">显示选中</button>
	<hr>
	<table class="gridtable" id="testGrid" border="1"
		style="width: 100%; margin-top: 10px;">
	</table>

	<div id="div1">
	
	</div>
	 <div id="myDiv">
		<button id="bt5">保存评分</button>
	</div>
	 
	
	<table id="table1" class="gridtable" style="display: none;"> 
			<tr>
				<td>1</td>
				<td>连续是4-5连涨，涨幅没有超过15%</td>
				<td><input type="text" style="width:50px" value="0"></td> 
			</tr> 
				<tr>
				<td>2</td>
				<td>连续涨幅超过5%</td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr> 
				<tr>
				<td>3</td>
				<td>换手率最大没有超过5-7%</td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr>  
				<tr>
				<td>4</td>
				<td>明显的前期长时间的横盘过，当前线很好，成一个拉升趋势。资本搞事</td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr> 
				<tr>
				<td>5</td>
				<td>有没有明显的热点，算不行业龙头和强势，股性如何，周K和日k有没有可能较大的波动</td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr>
			
			<tr>
				<td>6</td>
				<td>市值有没有超过50亿到200亿之间，过小危险，过大拉不动 </td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr> 
			<tr>
			    <td>7</td>
				<td>当前大盘在不在最高点，处于高位</td>
				<td><input type="text" style="width:50px"  value="0"></td> 
			</tr>
			<tr>
				<td>8</td>
				<td>最近的财务情况如何</td>
				<td><input type="text" style="width:50px"  value="0"></td>
			</tr> 
	</table>
	
	<script type="text/javascript">
	var order = "sum";  
	var descAsc="0";
	var trhead = '<thead><tr><th>序号</th><th>code</th><th>总换手率</th><th>几连涨</th><th>涨>5</th><th>跌>5</th><th>name</th><th>into1</th><th>note1</th></tr></thead>';

	$("#bt3").click(function(){
		order ="zhang5"; loadMsgDate()
	});
	$("#bt4").click(function(){
		order ="die5"; loadMsgDate()
	});
	$("#bt2").click(function(){ 
		order ="sum";loadMsgDate()
	});
	
	$("#addCls").click(function(){ 
		$.ajax({
			type : "get",
			url : "${pageContext.request.contextPath}/addCls", 
			dataType:'json',
			success : function(msg) {  
				console.log(msg); 
			}
		});   
	});
	
	function loadMsgDate(){
		$("#testGrid").html("");
		var text = $("#dateselect").find("option:selected").text(); 
		$("#testGrid").append(trhead);
		for(var i=0;i<alldate.length;i++){
			if(alldate[i].date == text){
				var listcontent = $.parseJSON(alldate[i].content);
				if(order=="sum"){
					 if(descAsc=="0"){
						 descAsc="1"
						 listcontent.sort(function(a, b) {
							    return a.sum - b.sum;
						 });
					 }else{
						 descAsc="0"
							 listcontent.sort(function(a, b) {
								    return b.sum - a.sum;
							 });
					 }
					
				}
				if(order=="zhang5"){
					if(descAsc=="0"){
						 descAsc="1"
							 listcontent.sort(function(a, b) {
								    return a.zhang5 - b.zhang5;
								});
					 }else{
						 descAsc="0"
							 listcontent.sort(function(a, b) {
								    return b.zhang5 - a.zhang5;
								});
					 }
					
				}
				if(order=="die5"){
					if(descAsc=="0"){
						 descAsc="1"
							 listcontent.sort(function(a, b) {
								    return a.die5 - b.die5;
								});
					 }else{
						 descAsc="0"
							 listcontent.sort(function(a, b) {
								    return b.die5 - a.die5;
								});
					 }
					
					
				}
				for(var j=0;j<listcontent.length;j++){
					var temp = listcontent[j];
					var tr = $("<tr/>");
					var td0 = $("<td/>");
					var td1 = $("<td name='stockCode'/>");
					var td1_1 = $("<td name='maxDate'/>");
					var td1_2 = $("<td name='minDate'/>");
					var td1_3 = $("<td name='count'/>");
					var td1_4 = $("<td name='cDate'/>");
					var td2 = $("<td name='tdsum' />");
					var td3 = $("<td name='ci' />");
					var td3_1 = $("<td name='zhang5'/>");
					var td3_2 = $("<td name='die5'/>");
					var td3_3 = $("<td name='name'/>"); 
					var td3_3_1 = $("<td name='into1'/>");
					var td3_4 = $("<td name='note1'/>");
					td3_4.attr("code",temp.code);
					td3_3_1.attr("code",temp.code);
					td0.text(j+1);
					td1.text(temp.code);
					//td1_1.text(temp.maxDate);
					//td1_2.text(temp.minDate);
					//td1_3.text(temp.count);
					//td1_4.text(temp.cDate);
					td2.text(temp.sum.toFixed(2));
					td3.text(alldate[i].ci);
					td3_1.text(temp.zhang5);
					td3_2.text(temp.die5);
					var diqv = "sh";
					if(temp.diqv==1){
						diqv="sz"
					}
					td3_3.html("<a href='https://quote.eastmoney.com/concept/"+diqv+temp.code+".html#fullScreenChart' target='_blank'>"+temp.stock+"</a>");
					td3_3_1.html("");
					tr.append(td0);
					tr.append(td1);
					//tr.append(td1_1);
					//tr.append(td1_2);
					//tr.append(td1_3);
					//tr.append(td1_4);
					tr.append(td2);
					tr.append(td3);
					tr.append(td3_1);
					tr.append(td3_2);
					tr.append(td3_3); 
					tr.append(td3_3_1)
					tr.append(td3_4);
					//tr.append(td5); 
					$("#testGrid").append(tr); 
					$("#count").text((j+1)+"个");
				} 
				break;
			}
		} 
		getPinfen();
	}
	$("#bt1").click(function(){
		var list = $("td[name=tdsum]");
		var maxnumber = $("#numberMax").val();
		var numberMin = $("#numberMin").val();
		for(var i=0;i<list.length;i++){
			var tdcontent = $(list[i]).text();
			if(parseFloat(tdcontent)<maxnumber || numberMin < parseFloat(tdcontent)){ 
				var sum = $("#count").text();
				var sum1 = parseInt(sum)-1;
				$(list[i]).parent().hide();
				$("#count").text(sum1);
			}
		}
	}); 
		$("#addshList").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/addSHList", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg); 
				}
			});  
		}); 
		var alldate;
		$("#getContent").click(function(){
			$("#dateselect").html("");
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/getContent", 
				data:{date:$("#date").val()},
				dataType:'json',
				success : function(msg) {  
					$("#testGrid").html("");
					if(msg.length>0){
						alldate = msg;
						var listcontent = $.parseJSON(msg[0].content); 
						$("#testGrid").append(trhead);
						for(var i=0;i<listcontent.length;i++){
							var temp = listcontent[i];
							var tr = $("<tr/>");
							var td0 = $("<td />");
							var td1 = $("<td name='stockCode'/>");
							var td1_1 = $("<td name='maxDate'/>");
							var td1_2 = $("<td name='minDate'/>");
							var td1_3 = $("<td name='count'/>");
							var td1_4 = $("<td name='cDate'/>");
							var td2 = $("<td name='tdsum'/>");
							var td3 = $("<td name='ci'/>");
							var td3_1 = $("<td name='zhang5'/>");
							var td3_2 = $("<td name='die5'/>");
							var td3_3 = $("<td name='stock'/>"); 
							var td3_3_1 = $("<td name='into1'/>");
							var td3_4 = $("<td name='note1'/>");
							td3_4.attr("code",temp.code);
							td3_3_1.attr("code",temp.code);
							td0.text(i+1);
							td1.text(temp.code);
							//td1_1.text(temp.maxDate);
							//td1_2.text(temp.minDate);
							//td1_3.text(temp.count);
							//td1_4.text(temp.cDate);
							
							td2.text(temp.sum.toFixed(2));
							td3.text(msg[0].ci);
							td3_1.text(temp.zhang5);
							td3_2.text(temp.die5); 
							td3_3_1.html("");
							tr.append(td0);
							tr.append(td1);
							//tr.append(td1_1);
							//tr.append(td1_2);
							//tr.append(td1_3);
							//tr.append(td1_4);
							tr.append(td2);
							tr.append(td3);
							tr.append(td3_1);
							tr.append(td3_2); 
							var diqv = "sh";
							if(temp.diqv==1){
								diqv="sz"
							}
							td3_3.html("<a href='https://quote.eastmoney.com/concept/"+diqv+temp.code+".html#fullScreenChart' target='_blank'>"+temp.stock+"</a>");
							tr.append(td3_3);
							tr.append(td3_3_1); 
							tr.append(td3_4);
							
							$("#testGrid").append(tr);
						}
					}
					for(var i=0;i<msg.length;i++){
						var opt ="<option value="+msg[i].date+">"+msg[i].date+"</option>";
						$("#dateselect").append(opt);
					}
					getPinfen();
				}
				
			});  
		});
		
	 
		
		$("#dateselect").change(function(){
			var text = $(this).find("option:selected").text();
			$("#testGrid").html(""); 
			$("#testGrid").append(trhead);
			for(var i=0;i<alldate.length;i++){
				if(alldate[i].date == text){
					var listcontent = $.parseJSON(alldate[i].content);
					for(var j=0;j<listcontent.length;j++){
						var temp = listcontent[j];
						var tr = $("<tr/>");
						var td0 = $("<td/>");
						var td1 = $("<td name='stockCode'/>");
						var td1_1 = $("<td name='maxDate'/>");
						var td1_2 = $("<td name='minDate'/>");
						var td1_3 = $("<td name='count'/>");
						var td1_4 = $("<td name='cDate'/>");
						var td2 = $("<td name='tdsum' />");
						var td3 = $("<td name='ci' />");
						var td3_1 = $("<td name='zhang5'/>");
						var td3_2 = $("<td name='die5'/>");
						var td3_3 = $("<td name='stock'/>");
						var td3_3_1 = $("<td name='into1'/>");
						var td3_4 = $("<td name='note1'/>");
						td3_4.attr("code",temp.code);
						td3_3_1.attr("cod",temp.code);
						td0.text(j+1);
						td1.text(temp.code);
						//td1_1.text(temp.maxDate); 
						//td1_2.text(temp.minDate);
						//td1_3.text(temp.count);
						//td1_4.text(temp.cDate);
						td2.text(temp.sum.toFixed(2));
						td3.text(alldate[i].ci);
						td3_1.text(temp.zhang5);
						td3_2.text(temp.die5);
						var diqv = "sh";
						if(temp.diqv==1){
							diqv="sz"
						}
						td3_3.html("<a href='https://quote.eastmoney.com/concept/"+diqv+temp.code+".html#fullScreenChart'  target='_blank'>"+temp.stock+"</a>");
						td3_3_1.html("");
						tr.append(td0);
						tr.append(td1);
						//tr.append(td1_1);
						//tr.append(td1_2);
						//tr.append(td1_3);
						//tr.append(td1_4);
						tr.append(td2);
						tr.append(td3);
						tr.append(td3_1);
						tr.append(td3_2);
						tr.append(td3_3);
						tr.append(td3_3_1);
						tr.append(td3_4);
						//tr.append(td4);
						//tr.append(td5); 
						$("#testGrid").append(tr); 
						$("#count").text((j+1)+"个");
					} 
				}
			}
			getPinfen();
		});
		 
		$("#getSelect").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/getSelect", 
				data:{date:$("#date").val(),zhang:$("#zhang").val()},
				dataType:'json',
				success : function(msg) {  
					console.log(msg);  
				}
			});  
		});
		$("#getSelect1").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/getSelect1", 
				data:{date1:$("#date1").val()},
				dataType:'json',
				success : function(msg) {  
					console.log(msg);  
				}
			});  
		});
		$("#getSelect2").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/getSelect2", 
				data:{date1:$("#date2").val()},
				dataType:'json',
				success : function(msg) {  
					console.log(msg);  
				}
			});  
		});
		$("#deleteSH").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/deleteSH", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg);
					 
				}
			});  
		});
		
		$("#addshList1").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/addSHList1", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg);
				}
			});  
		});
		
		
		$("#addszList").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/addszList", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg);
					 
				}
			});  
		});
		$("#addszList1").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/addszList1", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg);
					 
				}
			});  
		});
		$("#addszList2").click(function(){
			$.ajax({
				type : "get",
				url : "${pageContext.request.contextPath}/addszList2", 
				dataType:'json',
				success : function(msg) {  
					console.log(msg);
					 
				}
			});  
		});
		var listStock;
		function getPinfen(){ 
			var listtd = $("td[name=note1]"); 
			var listtd1 = $("td[name=into1]");
			for(var i=0;i<listtd.length;i++){
				//console.log($(listtd[i]).attr("code"));
				var textarea = $("<textarea/>").width(340).height(80); 
				$(listtd[i]).width(350).append(textarea);
				$(listtd1[i]).append(getinto1()).append("<font color='green' name='ft'>未选中<font>"); 
			}  
			$.ajax({
				   type: "get",
				   url : "${pageContext.request.contextPath}/getPinfen",   
				   success: function(msg){ 
					    for(var i=0;i<msg.length;i++){
					    	 for(var j=0;j<listtd.length;j++){
					    		 if($(listtd[j]).attr("code") == msg[i].code){
					    			 $(listtd[j]).children().append(msg[i].note1); 
					    			 if(msg[i].into1 ==1){
					    				 $(listtd1[j]).find("font").attr("color","red").text("已选中");
					    				 break;
					    			 } 
					    			
					    			 break;
					    		 } 
					    	 }
					    }
					    
					    
					    
				   }
				}); 
		}
		$("#bt5").click(function(){
			var listtd = $("td[name=note1]"); 
		 
			var arr = [];
			for(var i=0;i<listtd.length;i++){ 
				var obj = {}; 
				if($(listtd[i]).children().val()=="" || $(listtd[i]).children().val().length<=0){
					continue;
				}
				obj.code = $(listtd[i]).attr("code");
				obj.note1= $(listtd[i]).children().val();
				 
				arr.push(obj);
			}
			console.log(arr.length);
			var all = JSON.stringify(arr);
			$.ajax({
				type : "post",
				url : "${pageContext.request.contextPath}/addpinfen", 
				data:{all:all},
				dataType:'json',
				success : function(msg) {  
					alert("成功");
					 
				}
			});  
		});
		
		function getinto1(into1){
			var bt = $("<button/>");bt.text("加入");
			var bt1 = $("<button/>");bt1.text("取消");
			bt.click(function(){
				var code = $(this).parent().parent().attr("code");
				 
				change(code,1);
				
			});
			bt1.click(function(){
				var code = $(this).parent().parent().attr("code");
				change(code,0)
				
			});
			var div = $("<div/>");
			if(into1 == 1){
				return div.append("").append(bt1).append(bt);
			}
			return div.append("").append(bt1).append(bt);
		}
		
		function change(code,state){
			$.ajax({
				   type: "get",
				   url : "${pageContext.request.contextPath}/changeZX",   
				   data:{code:code,state:state},
				   success: function(msg){
					    alert(msg);
				   }
				});  
		}
		$("#addSN").click(function(){
			$.ajax({
			   type: "get",
			   url : "${pageContext.request.contextPath}/addGN",   
			 
			   success: function(msg){
				    alert(msg);
			   }
			}); 
		});
		$("#addHS").click(function(){
			$.ajax({
			   type: "get",
			   url : "${pageContext.request.contextPath}/addHS",    
			   success: function(msg){
				    alert(msg);
			   }
			}); 
		});
		var faft = 0;
		$("#bt6").click(function(){ 
			if(faft==0){
				faft =1;
			}else{
				faft =0;
			}  
			var aft = $("font[name=ft]");
			for(var i=0;i<aft.length;i++){
				var text = $(aft[i]).text();
				if(text =="未选中"){
					if(faft == 1){
						 $(aft[i]).parent().parent().show();
					 }else{
						 $(aft[i]).parent().parent().hide();
					 }	
				}
				 
			}
			
		}); 
		
		
		
		$(function(){
			//getPinfen();
		});
	</script>
</body>
</html>